﻿using System.ComponentModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SharpObservation.Tests
{

    using Dummy;

    [TestClass]
    public class ObservabeObjectTests
    {
        /// <summary>
        /// Tests the property changing invoked correctly.
        /// </summary>
        [TestMethod]
        public void TestPropertyChangingInvokedCorrectly()
        {
            var dummy = new NotifyDummy{ Name = "John" };

            Assert.AreEqual("John", dummy.Name);

            dummy.PropertyChanging +=
                (o, e) =>
                {
                    var args = e as PropertyChangingEventArgs;
                    Assert.AreSame(o, dummy);
                    Assert.AreEqual("Name", e.PropertyName);
                    Assert.IsNotNull(args);
                };
            dummy.Name = "Jane";
        }



        /// <summary>
        /// Tests the property changed invoked correctly.
        /// </summary>
        [TestMethod]
        public void TestPropertyChangedInvokedCorrectly()
        {
            var dummy = new NotifyDummy{ Name = "John" };

            Assert.AreEqual("John", dummy.Name);

            dummy.PropertyChanged +=
                (o, e) =>
                {
                    var args = e as PropertyChangedEventArgs;
                    Assert.AreSame(o, dummy);
                    Assert.AreEqual("Name", e.PropertyName);
                    Assert.IsNotNull(args);
                };

            dummy.Name = "Jane";
        }
    }
}
